$(document).on("pageInit", "#page_parkConfirm", function(e, pageId, $page) {
    my.givetitle('确认订单');
    var key=my.get_key(my.getCookie('token'));

    var parkingorderinfo =JSON.parse(sessionStorage.parkingorderinfo);

    console.log(parkingorderinfo);

    $('.parkingorderconfirm_carino').html(parkingorderinfo.car_brand_name+" "+parkingorderinfo.car_models_name+" "+parkingorderinfo.car_usercar_color);
    $('.parkingorderconfirm_car_plate').html(parkingorderinfo.parking_car_plate);
    $('.parkingorderconfirm_stores_name').html(parkingorderinfo.parking_stores_name);
    $('.parkingorderconfirm_startdate').html(parkingorderinfo.parking_starttime);
    $('.parkingorderconfirm_enddate').html(parkingorderinfo.parking_endtime);

    if(parkingorderinfo.is_rent==1 || parkingorderinfo.is_rent=="1")
    {
        $('.cartimeorderconfirm_carino').html(parkingorderinfo.car_brand_name+" "+parkingorderinfo.car_models_name+" "+parkingorderinfo.car_usercar_color);
        $('.cartimeorderconfirm_car_plate').html(parkingorderinfo.parking_car_plate);
        $('.cartimeorderconfirm_stores_name').html(parkingorderinfo.parking_stores_name);
        $('.cartimeorderconfirm_startdate').html(parkingorderinfo.parking_starttime);
        $('.cartimeorderconfirm_enddate').html(parkingorderinfo.parking_endtime);
    }
    else
    {
        $('.parkConfirm_cartimeinfo').hide();
        $('.parkConfirm_park_total_price').html(parkingorderinfo.park_total_price+"元");

    }

    $('.parkConfirmSubmit').click(function(){
        var pic1="";
        var pic2="";
        if(sessionStorage.parkingorderpictemp!=null)
        {
            var pictemp =JSON.parse(sessionStorage.parkingorderpictemp);
            pic1=pictemp.carpic1;
            pic2=pictemp.carpic2;
        }
        var info_parkpay={
            'user_id':my.getCookie('id'),
            'flight_number':parkingorderinfo.flight_number,
            'parking_starttime':parkingorderinfo.parking_starttime,
            'parking_endtime':parkingorderinfo.parking_endtime,
            'store_id':parkingorderinfo.store_id,


            'is_rent':parkingorderinfo.is_rent,
            'usercar_id':parkingorderinfo.usercar_id,
            'is_identity':parkingorderinfo.parking_car_is_identity,
            'carpic1':pic1,
            'carpic2':pic2

        }
        var info_parkpay1=JSON.stringify(info_parkpay);
        info_parkpay=my.cryptoASEencrypt(info_parkpay1,key);

        $.ajax({
            type: "post",
            url: api.addparkingorder2,
            data: {
                'api_value': info_parkpay
            },
            async: true,
            error: function () {
                $.hidePreloader()
                $.toast("提交失败，请重试");
            },
            success: function (data) {
                if(data.match("err_code")!=null){
                    switch(JSON.parse(data).err_code)
                    {
                        case 40003:
                            my.tokenExpire()
                            break;
                        default:
                            $.toast(JSON.parse(data).err_msg);
                    }

                }else {
                    data=JSON.parse(data);
                    data=JSON.parse(my.cryptoASEdencrypt(data.data,key));
                    //alert(data.waitfp_id);alert(data.parking_id);
                    if (parkingorderinfo.is_rent == 1) {
                        sessionStorage.parkRecoTime = parkingorderinfo.parking_starttime + '-' + parkingorderinfo.parking_endtime;
                        $.router.load(parkRecommendUrl2, true);
                    } else {
                        sessionStorage.parkRecoTime = parkingorderinfo.parking_starttime + '-' + parkingorderinfo.parking_endtime;
                        sessionStorage.park_waitfp_id = data.waitfp_id
                        sessionStorage.park_parking_id = data.parking_id
                        // $.router.loadPage("zhifu_Park.html");
                        $.router.load(zhifu_ParkUrl2, true);
                    }
                }
            }
        });
    });

   /* $('#pay_jszj_endtime').val(sessionStorage.parking_endtime)
    $('#Estimated-carprice').val(sessionStorage.official_price)
    $('#Estimated-carplate').val(sessionStorage.parking_car_plate)
    $('#Estimated-time').val(sessionStorage.parking_starttime+'-'+sessionStorage.parking_endtime)
    $('#Estimated-local').val(sessionStorage.flight_startPlace).attr('title',sessionStorage.flight_startPlace_id)
    $('.pay_jszj').click(function(){
        var pay_jszj={
            'starttime':$('#pay_jszj_starttime').val(),
            'endtime':$('#pay_jszj_endtime').val(),
            'buying_price':$('#Estimated-carprice').val(),
            'timedifference':$('#Estimated-old').val(),
            'store_id':sessionStorage.flight_store_id,
        }
        console.log(pay_jszj)
        pay_jszj=JSON.stringify(pay_jszj)
        pay_jszj=my.cryptoASEencrypt(pay_jszj,key)
        $.ajax({
            type:"post",
            url:api.calculaterent,
            data:{
                'api_value':pay_jszj
            },
            async:true,
            error:function(){
                $.hidePreloader()
                $.toast("提交失败，请重试");
            },
            success:function(data){
                $.hidePreloader()
                if(data.match("err_code")!=null){
                    switch(JSON.parse(data).err_code)
                    {
                        case 40003:
                            my.tokenExpire()
                            break;
                        default:
                            $.toast(JSON.parse(data).err_msg);
                    }

                }else{
                    data=JSON.parse(data)
                    data=JSON.parse(my.cryptoASEdencrypt(data.data,key))
                    console.log(data)
                    $('#pay_workprice').text(data.workprice)
                    $('#pay_weekprice').text(data.weekprice)
                    $('#pay_festivalprice').text(data.festivalprice)
                    $('#pay_total_prices').text(data.total_prices)

                }
            },
        });
        //ajax结束
    })
    //$('.parkChoosePrice-p').html(sessionStorage.park_total_price+'<label>元</label>')
*/
});
